<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <title>注册</title>
    <style>
        body {
            background-image: url("imgs/reg_img.png");
            background-repeat: no-repeat;
            background-attachment: fixed;
            background-size: cover;
        }

        card__body, .el-main {
            opacity: 0.85;
        }
    </style>
</head>
<body>
<div id="app">
    <el-container>
        <el-header>
        </el-header>
        <el-main>
            <div>
                <p style="margin-left: 100px; font-weight: bold; font-size:30px;text-align: center">欢迎来到星光书城</p>
            </div>
            <el-card style="width: 600px;height: 500px;margin: 0 auto;
                background-color: white;font-weight: bold">
                <el-form label-width="100px" style="width: 400px;margin: 50px auto">
                    <el-form-item label="用户名">
                        <el-input type="text" placeholder="请输入用户名" v-model="user.username"></el-input>
                    </el-form-item>
                    <el-form-item label="密码">
                        <el-input type="password" placeholder="请输入密码" v-model="user.password"></el-input>
                    </el-form-item>
                    <el-form-item label="性别">
                        <template>
                            <el-radio v-model="user.gender" label="1">男</el-radio>
                            <el-radio v-model="user.gender" label="2">女</el-radio>
                        </template>
                    </el-form-item>

                    <el-form-item label="电话">
                        <el-input type="text" placeholder="请输入你的电话" v-model="user.phone"></el-input>
                    </el-form-item>
                    <el-form-item label="邮箱">
                        <el-input type="text" placeholder="请输入邮箱" v-model="user.email"></el-input>
                    </el-form-item>
                    <div>
                        <el-form-item style="width: 250px;float: left" label="邮箱验证码">
                            <el-input type="text" placeholder="请输入邮箱验证码" v-model="user.card"></el-input>
                        </el-form-item>
                        <el-button style="float: right" type="danger" @click="getCard()">获取验证码</el-button>
                    </div>
                    <br><br><br>
                    <el-form-item align="center">
                        <el-button type="primary" @click="reg()" style="margin-right: 100px">注册</el-button>
                    </el-form-item>
                </el-form>
            </el-card>
        </el-main>
    </el-container>
</div>
</body>
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<!-- import axios -->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                user: {
                    username: "",
                    password: "",
                    phone: "",
                    email: "",
                    gender: "",
                    card: ""
                }
            }
        },
        methods: {

            reg() {
                axios.post("/user/reg", v.user).then(function (response) {
                    alert("注册成功!")
                    let responseBody = response.data;

                    location.href = '/newLogin.html'
                })
            },
            getCard() {

            }
        }
    })
</script>
</html>